package com.ruoyi.yf.service.impl;

import java.util.List;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.yf.domain.YfYcgx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.yf.mapper.YfMedicalWasteAndHospitalRelationshipMapper;
import com.ruoyi.yf.domain.YfMedicalWasteAndHospitalRelationship;
import com.ruoyi.yf.service.IYfMedicalWasteAndHospitalRelationshipService;
import com.ruoyi.common.core.text.Convert;

/**
 * 医废处置机构、医疗机构关系Service业务层处理
 *
 * @author XiaoYi...
 * @date 2020-08-14
 */
@Service
public class YfMedicalWasteAndHospitalRelationshipServiceImpl implements IYfMedicalWasteAndHospitalRelationshipService {
    @Autowired
    private YfMedicalWasteAndHospitalRelationshipMapper yfMedicalWasteAndHospitalRelationshipMapper;

    /**
     * 查询医废处置机构、医疗机构关系
     *
     * @param id 医废处置机构、医疗机构关系ID
     * @return 医废处置机构、医疗机构关系
     */
    @Override
    public YfMedicalWasteAndHospitalRelationship selectYfMedicalWasteAndHospitalRelationshipById(Long id) {
        return yfMedicalWasteAndHospitalRelationshipMapper.selectYfMedicalWasteAndHospitalRelationshipById(id);
    }

    /**
     * 查询医废处置机构、医疗机构关系列表
     *
     * @param yfMedicalWasteAndHospitalRelationship 医废处置机构、医疗机构关系
     * @return 医废处置机构、医疗机构关系
     */
    @Override
    public List<YfMedicalWasteAndHospitalRelationship> selectYfMedicalWasteAndHospitalRelationshipList(YfMedicalWasteAndHospitalRelationship yfMedicalWasteAndHospitalRelationship) {
        return yfMedicalWasteAndHospitalRelationshipMapper.selectYfMedicalWasteAndHospitalRelationshipList(yfMedicalWasteAndHospitalRelationship);
    }



    /**
     * 新增医废处置机构、医疗机构关系
     *
     * @param yfMedicalWasteAndHospitalRelationship 医废处置机构、医疗机构关系
     * @return 结果
     * 过时的医处关系
     */
    @Override
    public int insertYfMedicalWasteAndHospitalRelationship(YfMedicalWasteAndHospitalRelationship yfMedicalWasteAndHospitalRelationship) {
        yfMedicalWasteAndHospitalRelationship.setCreateTime(DateUtils.getNowDate());
        return yfMedicalWasteAndHospitalRelationshipMapper.insertYfMedicalWasteAndHospitalRelationship(yfMedicalWasteAndHospitalRelationship);
    }

    /**
     *
     *
     * @param yfMedicalWasteAndHospitalRelationship 医废处置机构、医疗机构关系
     * @return 结果
     * 新的医处关系
     */
    /**
     * 修改医废处置机构、医疗机构关系
     *
     * @param yfMedicalWasteAndHospitalRelationship 医废处置机构、医疗机构关系
     * @return 结果
     */
    @Override
    public int updateYfMedicalWasteAndHospitalRelationship(YfMedicalWasteAndHospitalRelationship yfMedicalWasteAndHospitalRelationship) {
        yfMedicalWasteAndHospitalRelationship.setUpdateTime(DateUtils.getNowDate());
        return yfMedicalWasteAndHospitalRelationshipMapper.updateYfMedicalWasteAndHospitalRelationship(yfMedicalWasteAndHospitalRelationship);
    }

    /**
     * 删除医废处置机构、医疗机构关系对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteYfMedicalWasteAndHospitalRelationshipByIds(String ids) {
        return yfMedicalWasteAndHospitalRelationshipMapper.deleteYfMedicalWasteAndHospitalRelationshipByIds(Convert.toStrArray(ids));
    }

    @Override
    public int selectRelationshipSum(String ids) {
        return yfMedicalWasteAndHospitalRelationshipMapper.selectRelationshipSum(Convert.toStrArray(ids));
    }


    /**
     * 删除医废处置机构、医疗机构关系信息
     *
     * @param id 医废处置机构、医疗机构关系ID
     * @return 结果
     */
    @Override
    public int deleteYfMedicalWasteAndHospitalRelationshipById(Long id) {
        return yfMedicalWasteAndHospitalRelationshipMapper.deleteYfMedicalWasteAndHospitalRelationshipById(id);
    }

    /**
     * 验证机构是否签订三方医废垃圾处理合同
     *
     * @param deptId
     * @return
     */
    @Override
    public String checkMedicalWasteContract(Long deptId) {
        int i = yfMedicalWasteAndHospitalRelationshipMapper.checkMedicalWasteContract(deptId);
        System.out.println("cunzai：" + i);
        if (i == 1) {
            return UserConstants.MEDICAL_WASTE_YES;
        }
        return UserConstants.MEDICAL_WASTE_NOT;

    }
}
